package com.ezops.dto;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

public class MasterAgreementChartModel implements Serializable {

	public static List<MasterAgreementChartModel> adaptTo(
			Map<String, Integer> data) {
		List<MasterAgreementChartModel> allModels = new ArrayList<>(data.size());
		for (Entry<String, Integer> entry : data.entrySet()) {
			MasterAgreementChartModel model = new MasterAgreementChartModel();
			model.setPartyId(removeDoubleQuotes(entry.getKey()));
			model.setAgreementTypeCount(entry.getValue());
			allModels.add(model);
		}
		return allModels;
	}

	/**
	 * 
	 */
	private static final long serialVersionUID = -377946445388012514L;
	private String partyId;
	private Integer agreementTypeCount;

	public String getPartyId() {
		return partyId;
	}

	public void setPartyId(String partyId) {
		this.partyId = partyId;
	}

	public Integer getAgreementTypeCount() {
		return agreementTypeCount;
	}

	public void setAgreementTypeCount(Integer agreementTypeCount) {
		this.agreementTypeCount = agreementTypeCount;
	}
	
	private static String getValue(String value) {
		return value == null ? "" : value;
	}

	private static String removeDoubleQuotes(String value) {
		String checkValue = getValue(value);
		return checkValue.replaceAll("^\"|\"$", "");
	}

}
